From 5e9b89146b50610c636c6b1729fded12488ea0b2 Mon Sep 17 00:00:00 2001 From: "kfraser@localhost.localdomain" Date: Thu, 30 Aug 2007 11:01:39 +0100 Subject: [PATCH] xen: Understand the E820_UNUSABLE (type code 5) memory type. Signed-off-by: Joseph Cihula Signed-off-by: Keir Fraser --- xen/arch/x86/domain_build.c | 10 ++++++++++ xen/arch/x86/e820.c | 9 +++++++-- xen/arch/x86/mm.c | 4 +++- xen/arch/x86/setup.c | 3 +-- xen/include/asm-x86/e820.h | 1 + 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/domain_build.c b/xen/arch/x86/domain_build.c index 4cfd0433c1..a7927c6f63 100644 --- a/xen/arch/x86/domain_build.c +++ b/xen/arch/x86/domain_build.c @@ -989,6 +989,16 @@ int __init construct_dom0( rc |= iomem_deny_access(dom0, mfn, mfn); } + /* Remove access to E820_UNUSABLE I/O regions. */ + for ( i = 0; i < e820.nr_map; i++ ) + { + if ( e820.map[i].type != E820_UNUSABLE) + continue; + mfn = paddr_to_pfn(e820.map[i].addr); + nr_pages = (e820.map[i].size + PAGE_SIZE - 1) >> PAGE_SHIFT; + rc |= iomem_deny_access(dom0, mfn, mfn + nr_pages - 1); + } + BUG_ON(rc != 0); return 0; diff --git a/xen/arch/x86/e820.c b/xen/arch/x86/e820.c index 797ccc0a7e..835a0f76f3 100644 --- a/xen/arch/x86/e820.c +++ b/xen/arch/x86/e820.c @@ -41,7 +41,8 @@ static void __init print_e820_memory_map(struct e820entry *map, int entries) (unsigned long long)(map[i].addr), (unsigned long long)(map[i].addr + map[i].size)); switch (map[i].type) { - case E820_RAM: printk("(usable)\n"); + case E820_RAM: + printk("(usable)\n"); break; case E820_RESERVED: printk("(reserved)\n"); @@ -52,7 +53,11 @@ static void __init print_e820_memory_map(struct e820entry *map, int entries) case E820_NVS: printk("(ACPI NVS)\n"); break; - default: printk("type %u\n", map[i].type); + case E820_UNUSABLE: + printk("(unusable)\n"); + break; + default: + printk("type %u\n", map[i].type); break; } } diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 9af4f6ff5f..5ff93f4d34 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -213,7 +213,9 @@ void __init arch_init_memory(void) /* Any areas not specified as RAM by the e820 map are considered I/O. */ for ( i = 0, pfn = 0; pfn < max_page; i++ ) { - while ( (i < e820.nr_map) && (e820.map[i].type != E820_RAM) ) + while ( (i < e820.nr_map) && + (e820.map[i].type != E820_RAM) && + (e820.map[i].type != E820_UNUSABLE) ) i++; if ( i >= e820.nr_map ) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 3a6c3d7a6a..31d669a207 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -610,8 +610,7 @@ void __init __start_xen(unsigned long mbi_p) ((u64)map->base_addr_high << 32) | (u64)map->base_addr_low; e820_raw[e820_raw_nr].size = ((u64)map->length_high << 32) | (u64)map->length_low; - e820_raw[e820_raw_nr].type = - (map->type > E820_NVS) ? E820_RESERVED : map->type; + e820_raw[e820_raw_nr].type = map->type; e820_raw_nr++; bytes += map->size + 4; diff --git a/xen/include/asm-x86/e820.h b/xen/include/asm-x86/e820.h index 1d3a981f2e..69643949ad 100644 --- a/xen/include/asm-x86/e820.h +++ b/xen/include/asm-x86/e820.h @@ -8,6 +8,7 @@ #define E820_RESERVED 2 #define E820_ACPI 3 #define E820_NVS 4 +#define E820_UNUSABLE 5 struct e820entry { uint64_t addr; -- 2.30.2